let resizeObserver = null
let timer = null

export default function (el, timeout, callback) {
  if(resizeObserver) resizeObserver.disconnect();
  resizeObserver = new ResizeObserver(entries => {
    if(timer) clearTimeout(timer);
    timer = setTimeout(() => {
      callback(entries);
    }, timeout)
  });
  resizeObserver.observe(el);
}